import request from '@/utils/request'

const URL =  "http://localhost:8080"
export function fetchList(params) {
    return request({
        url: '/post/list',
        method: 'get',
        params: params
    })
}

export function fetchFocus() {
    return request({
        url: '/focus/list',
        method: 'get',
        params: {}
    })
}

export function fetchCategory() {
    return request({
        url: URL +'/category/queryAllCategory',
        method: 'get',
        params: {}
    })
}

export function fetchFriend() {
    return request({
        url: '/friend',
        method: 'get',
        params: {}
    })
}

export function fetchSocial() {
    return request({
        url: '/social',
        method: 'get',
        params: {}
    });
}

export function fetchSiteInfo() {
    return request({
        url: '/site',
        method: 'get',
        params: {}
    })
}

export function fetchComment() {
    return request({
        url: '/comment',
        method: 'get',
        params: {}
    })
}
// ==============
export function blogList(current, size) {
    return request({
        url: URL + '/blog/queryAllBlog',
        method: 'get',
        params:{
            current: current,
            size: size
        }
    })
}
export function tagList() {
    return request({
        url: URL + '/tag/queryHotTag',
        method: 'get',
        params: {}
    })
}
//获取所有分类
export function categoryList() {
    return request({
        url: URL + '/category/queryAllCategory',
        method: 'get',
        params: {}
    })
}

export function queryArticleById(params) {
    return request({
        url: URL + '/blog/queryBlogById',
        method: 'get',
        params: params
    })
}

export function replay(data) {
    return request({
        url: URL + '/blog/queryBlogById',
        method: 'get',
        params: params
    })
}

export function queryArticleByCategory(current,size,categoryName) {
    return request({
        url: URL + '/category/queryBlogByCategory',
        method: 'get',
        params: {
            current:current,
            size:size,
            categoryName: categoryName
        }
    })
}

//根据关键字查文章
export function queryBlogByKey(key,current,size) {
    return request({
        url: URL + '/blog/queryBlogByKey',
        method: 'get',
        params: {
            current:current,
            size:size,
            key: key
        }
    })
}

//根据文章id获取标签
export function queryTagByArticleId(id) {
    return request({
        url: URL + '/tag/queryTagByArticleId?id='+id,
        method: 'get',
    })
}

// 图片模块
//查询全部图片
export function queryPictureList(id,current,size) {
    return request({
        url: URL + '/picture/list',
        method: 'get',
        params:{
            current: current,
            size: size,
            category_id: id
        }
    })
}
//根据id查询图片
export function queryPictureById(id) {
    return request({
        url: URL + '/picture?id=' + id,
        method: 'get',
    })
}

//获取视频列表
export function queryVideoList(id,current,size) {
    return request({
        url: URL + '/video/list',
        method: 'get',
        params: {
            current: current,
            size: size,
            category_id: id
        }
    })
}
//查前6张相同分类图片
export function queryPictureByCategory(id) {
    return request({
        url: URL + '/picture/byCategory',
        method: 'get',
        params: {
            category_id: id
        }
    })
}

//根据cookie获取用户信息
export function getUserByToken() {
    return request({
        url: URL + '/user/token',
        method: 'get'
    })
}

//链接
export function getLink() {
    return request({
        url: URL + '/link/list',
        method: 'get'
    })
}

